import Taro from '@tarojs/taro-rn';
import * as tslib_1 from "tslib";
import React from 'react';
import { Component } from "@tarojs/taro-rn";
import { View, ScrollView, Text } from "@tarojs/components-rn";
import { inject, observer } from "@tarojs/mobx-rn";
import { getRuntime, technicalTitleArr, typeOfJobArr, majorTypeArr } from "../../utils/common";
import indexStyleSheet from "./index_styles";
var _styleSheet = indexStyleSheet;

function _getClassName() {
  var className = [];
  var args = arguments[0];
  var type = Object.prototype.toString.call(args).slice(8, -1).toLowerCase();

  if (type === 'string') {
    args = args.trim();
    args && className.push(args);
  } else if (type === 'array') {
    args.forEach(function (cls) {
      cls = _getClassName(cls).trim();
      cls && className.push(cls);
    });
  } else if (type === 'object') {
    for (var k in args) {
      k = k.trim();

      if (k && args.hasOwnProperty(k) && args[k]) {
        className.push(k);
      }
    }
  }

  return className.join(' ').trim();
}

function _getStyle(classNameExpression) {
  var className = _getClassName(classNameExpression);

  var classNameArr = className.split(/\s+/);
  var style = [];

  if (classNameArr.length === 1) {
    style.push(_styleSheet[classNameArr[0].trim()]);
  } else {
    classNameArr.forEach(function (cls) {
      style.push(_styleSheet[cls.trim()]);
    });
  }

  return style;
}

let Personnel = class Personnel extends Component {
  constructor(props) {
    super(props);
    this.state = {
      technicalTitleArr: technicalTitleArr,
      allProvince: [],
      majorTypeArr,
      typeOfJobArr,
      currentNavId: 0
    };
  }
  componentWillMount() {
    Taro.setNavigationBarTitle({ title: '工程人才中心' });
    this.getAllProvince();
  }
  getAllProvince() {
    let { AreaStore } = this.props.stores;
    AreaStore.getAllProvinceFromLocal({
      callBack: res => {
        this.setState({
          allProvince: res
        }, () => {});
      }
    });
  }
  handelRouter(url = '/pages/index/index') {
    getRuntime().navigateTo(url);
  }
  changeNav(currentNavId) {
    this.setState({
      currentNavId
    });
  }
  render() {
    let { currentNavId, technicalTitleArr, allProvince } = this.state;
    return <View style={_styleSheet["personnel-index"]}>
        <ScrollView scrollX={true} style={_styleSheet["scroll-view-nav"]}>
          <View onClick={this.changeNav.bind(this, 0)} style={_getStyle(currentNavId === 0 ? 'scroll-item scroll-item-on' : 'scroll-item')}>人才库<Text style={_styleSheet["line"]} /></View>
          <View onClick={this.changeNav.bind(this, 1)} style={_getStyle(currentNavId === 1 ? 'scroll-item scroll-item-on' : 'scroll-item')}>招聘信息<Text style={_styleSheet["line"]} /></View>
        </ScrollView>

        <View style={_styleSheet["interval"]} />

        <View style={_styleSheet["select-option"]}>
          <View style={_styleSheet["option-item"]}>
            <View style={[_styleSheet["option"], _styleSheet["all"], _styleSheet["option-active"]]}>全部</View>
            <ScrollView scrollX scrollWithAnimation onScroll={this.onScroll} style={_styleSheet["scrollview"]}>
              {technicalTitleArr.map(item => {
              return <View key={item} style={_styleSheet["option"]}>{item}</View>;
            })}
            </ScrollView>
          </View>
          <View style={_styleSheet["option-item"]}>
            <View style={[_styleSheet["option"], _styleSheet["all"], _styleSheet["option-active"]]}>全部</View>
            <ScrollView scrollX scrollWithAnimation onScroll={this.onScroll} style={_styleSheet["scrollview"]}>
              {allProvince.map(item => {
              return <View key={item.value} style={_styleSheet["option"]}>{item.label}</View>;
            })}
            </ScrollView>
          </View>
          <View style={_styleSheet["option-item"]}>
            <View style={[_styleSheet["option"], _styleSheet["all"], _styleSheet["option-active"]]}>全部</View>
            <ScrollView scrollX scrollWithAnimation onScroll={this.onScroll} style={_styleSheet["scrollview"]}>
              <View style={_styleSheet["option"]}>建筑</View>
              <View style={_styleSheet["option"]}>公路</View>
              <View style={_styleSheet["option"]}>铁路</View>
              <View style={_styleSheet["option"]}>民航机厂</View>
              <View style={_styleSheet["option"]}>港口与航道</View>
            </ScrollView>
          </View>
          <View style={_styleSheet["option-item"]}>
            <View style={[_styleSheet["option"], _styleSheet["all"], _styleSheet["option-active"]]}>全部</View>
            <ScrollView scrollX scrollWithAnimation onScroll={this.onScroll} style={_styleSheet["scrollview"]}>
              <View style={_styleSheet["option"]}>挂职</View>
              <View style={_styleSheet["option"]}>全职</View>
              <View style={_styleSheet["option"]}>兼职</View>
            </ScrollView>
          </View>

        </View>

        <View style={_styleSheet["interval"]} />

        <View style={_styleSheet["list-06"]}>
          <View onClick={this.handelRouter.bind(this, '/pages/personnel/detail')} style={_styleSheet["list-06-item"]}>
            <View style={_styleSheet["item-title"]}>
              <View style={_styleSheet["title"]}>
                昆明高薪招聘二级建造师
                <Text style={_styleSheet["label"]}>全职</Text>
              </View>
              <View style={_styleSheet["address"]}>云南-昆明</View>
            </View>
            <View style={_styleSheet["item-info"]}>
              <View style={_styleSheet["info"]}>
                <Text style={_styleSheet["op"]}>面议</Text>
                <Text style={_styleSheet["i"]}>大专</Text>
                <Text style={_styleSheet["i"]}>5年</Text>
                <Text style={_styleSheet["i"]}>大专</Text>
                <Text style={_styleSheet["i"]}>大专</Text>
              </View>
              <View style={_styleSheet["btn-view"]}>
                查看
              </View>
            </View>
          </View>

          <View style={_styleSheet["list-06-item"]}>
            <View style={_styleSheet["title"]}>
              昆明高薪招聘二级建造师
              <Text style={_styleSheet["label"]}>全职</Text>
            </View>
            <View style={_styleSheet["item-info"]}>
              <View style={_styleSheet["info"]}>
                <Text style={_styleSheet["op"]}>面议</Text>
                <Text style={_styleSheet["i"]}>大专</Text>
                <Text style={_styleSheet["i"]}>5年</Text>
                <Text style={_styleSheet["i"]}>大专</Text>
                <Text style={_styleSheet["i"]}>大专</Text>
              </View>
              <View style={_styleSheet["btn-view"]}>
                查看
              </View>
            </View>
          </View>

          <View style={_styleSheet["list-06-item"]}>
            <View style={_styleSheet["item-title"]}>
              <View style={_styleSheet["title"]}>
                昆明高薪招聘二级建造师
                <Text style={_styleSheet["label"]}>全职</Text>
              </View>
              <View style={_styleSheet["address"]}>云南-昆明</View>
            </View>
            <View style={_styleSheet["item-info"]}>
              <View style={_styleSheet["info"]}>
                <Text style={_styleSheet["op"]}>面议</Text>
                <Text style={_styleSheet["i"]}>大专</Text>
                <Text style={_styleSheet["i"]}>5年</Text>
                <Text style={_styleSheet["i"]}>大专</Text>
                <Text style={_styleSheet["i"]}>大专</Text>
              </View>
              <View style={_styleSheet["btn-view"]}>
                查看
              </View>
            </View>
          </View>
        </View>

        <View style={_styleSheet["footer-personnel"]}>
          <View onClick={this.handelRouter.bind(this, '/pages/index/position')} style={[_styleSheet["btn"], _styleSheet["btn1"]]}>发布职位</View>
          <View onClick={this.handelRouter.bind(this, '/pages/index/rresume')} style={[_styleSheet["btn"], _styleSheet["btn2"]]}>填写简历</View>
        </View>
      </View>;
  }
};
Personnel = tslib_1.__decorate([inject("stores"), observer], Personnel);
export default Personnel;